package com.qf.day07;

import java.util.Comparator;

public class Animal implements Comparable<Animal>{
    private String type;
    private int age;
    private String sex;

    public Animal() {
    }

    public Animal(String type, int age, String sex) {
        this.type = type;
        this.age = age;
        this.sex = sex;
    }

    @Override
    public String toString() {
        return "Animal{" +
                "type='" + type + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                '}';
    }


    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    protected void eat() {
        System.out.println(getType() + "在吃");
    }
    protected void sleep() {
        System.out.println(getType() +"在睡");
    }

    @Override
    public int compareTo(Animal o) {
        return this.getAge() - o.getAge();
    }
}
